import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
function resolve(resolvePath) {
  return path.join(__dirname, resolvePath);
}
// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      iconDirs: [resolve('./src/icon/svg')],
      // 指定symbolId格式
      symbolId: 'icon-[name]',
      svgoOptions: {
          plugins: [  
            {
                // 清除svg部分属性
                name: 'removeAttrs',
                params: { attrs: ['fill'] }
            }
          ]
       }
    })

  ],
  devServer: {
    proxy: {
      // "/test/": {
      //   target: "http://localhost:5174",
      //   changeOrigin: true,
      // },
      "/api/": {
        target: "https://www.tuguan.net",
        changeOrigin: true,
      },
      "/publish/":{
        target: "https://www.tuguan.net",
        changeOrigin: true,
      },
      "/apiTester/":{
        target: "https://www.tuguan.net",
        changeOrigin: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve('src')
    }
  }
})
